﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DCT.CodeBox.BMS.Code.Datas.Interfaces
{
    /// <summary>
    /// 创建普通数据操作的CRUD
    /// </summary>
    /// <typeparam name="TDataModel"></typeparam>
    /// <typeparam name="TIdentifier"></typeparam>
    public interface ICommonData<TDataModel, TIdentifier>
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="data">新增数据</param>
        /// <param name="id">输出Id</param>
        /// <returns></returns>
        DataResult Insert(TDataModel data, out TIdentifier id);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="data">更新的数据</param>
        /// <returns></returns>
        DataResult Update(TDataModel data);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        DataResult Delete(TIdentifier id);

        /// <summary>
        /// 物理删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        DataResult RealDelete(TIdentifier id);

        /// <summary>
        /// 根据标识查询一个数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        TDataModel QueryOne(TIdentifier id);

        /// <summary>
        /// 查询所有数据
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        IEnumerable<TDataModel> QueryAll(QueryInfo queryInfo);

        /// <summary>
        /// 查询分页数据
        /// </summary>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        IEnumerable<TDataModel> QueryPager(PagerInfo pageInfo);
    }
}
